import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login.vue'),
  },
  {
    path: '/',
    name: 'layout',
    component: () => import('@/views/Layout.vue'),
    children: [
      {
        path: '', // 默认子路由
        name: 'home',
        component: () => import('@/views/HomePage.vue'),
      },
      {
        path: 'qa',
        name: 'qa',
        component: () => import('@/views/QaPage.vue'),
      },
      {
        path: 'video',
        name: 'video',
        component: () => import('@/views/VideoPage.vue'),
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('@/views/MyPage.vue'),
      },
    ],
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/Search.vue'),
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/Article.vue'),
    props: true,
  },
  {
    path: '/user/profile',
    name: 'user-profile',
    component: () => import('@/views/UserProfile.vue'),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
